java_library: output JNI headers generated by javac#13
Draft
chrisnovakovic wants to merge 3 commits intoplease-build:masterfrom
Draft
java_library: output JNI headers generated by javac#13chrisnovakovic wants to merge 3 commits intoplease-build:masterfrom
java_library: output JNI headers generated by javac#13chrisnovakovic wants to merge 3 commits intoplease-build:masterfrom
Conversation
Contributor
Author
|
(This is a mirror of thought-machine/please#2525.) |
The Java compiler outputs header files for Java sources that use the Java Native Interface (JNI), but there's currently no way for them to be consumed by the native-code components that depend on them, preventing them from being built. Provide the JNI headers as outputs of `java_library` when `cc_hdrs` is required. This allows native-code JNI components written in C/C++ to be built by including the `java_library` target as a dependency.
4f503e8 to
8565012
Compare
chrisnovakovic
commented
Aug 9, 2022
|
|
||
| def _jni_header_outputs(name, output): | ||
| for hdr_path in output: | ||
| if hdr_path != "": |
Contributor
Author
There was a problem hiding this comment.
This is just to guard against the command outputting \n when no headers are generated.
chrisnovakovic
commented
Aug 9, 2022
| }, | ||
| cmd = " && ".join([ | ||
| "mkdir -p _jni", | ||
| f"{javac_cmd} -h _jni >/dev/null 2>&1", |
Contributor
Author
There was a problem hiding this comment.
Silencing the output of javac here as a precaution because it's possible to instruct javac to output to stdout instead of stderr using a command line option (i.e. via javac_flags) - it's an edge case, but one that'll break this target if it's used. The main target will still show compilation errors for the class files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Java compiler outputs header files for Java sources that use the Java Native Interface (JNI), but there's currently no way for them to be consumed by the native-code components that depend on them, preventing them from being built.
Provide the JNI headers as outputs of
java_librarywhencc_hdrsis required. This allows native-code JNI components written in C/C++ to be built by including thejava_librarytarget as a dependency.